package com.wm.action;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;

import com.wm.bean.Dish;
import com.wm.bean.Restaurant;
import com.wm.dao.DishDao;
import com.wm.service.MyRestaurantService;
import com.wm.service.RestaurantService;
import com.wm.vo.RestaurantListVO;

import cn.itcast.service.PersonService;
import com.wm.vo.*;
public class XiaodianAction extends DispatchAction {
	@Resource MyRestaurantService myRestaurantService;

/**
 * 展示小店
 * 
 */
	
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response){
		
		if (request.getParameter("rid").equals("")) {
			return mapping.findForward("notfind");
		}
		String rid = request.getParameter("rid").trim();
		//String rid = "hubei";
		List<Dish> dishList = myRestaurantService.ShowMyRestaurant(rid);
		
		System.out.println(dishList.size());
		for(Dish d:dishList){
			System.out.println(d.getName());
		}
		request.setAttribute("dishs", dishList);
		if (dishList.size()>0) {
			return mapping.findForward("success");
		}else {
			return mapping.findForward("notfind");
		}
		
	}

}
